/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__resp_data_analysis.c                            */
/*  NOTE      =                                                    */
/*  DATE      = 2016/04/1 by jikw                                  */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include <cassandra/cassandra_core.h>
#include "frsutl.h"
#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "frreport_comm.h"
#include "../../../src/module/cassandra/config.h"

#include "frbyte_buffer.h"
#include "apmtest_cunit.h"

typedef struct __st_cassandra_report_list {
    struct timeval st_request_time;
    Frlist_header *p_lst_comm;
    Frlist_header *p_lst_req;
} cassandra_report_list;

typedef struct __st_L7session_cassandra_private
{
    L4_transaction st_l4_trans;                       //数据
    Frreport_body_data *p_st_body_data_req;
    Frreport_body_data *p_st_body_data_resp;
    Frhash_header *p_report_list_cassandra;           //未上报的请求
    Frbyte_Packet *p_req_packet;                      //存请求bytebuff数据
    Frbyte_Packet *p_resp_packet;                     //存相应bytebuff数据
    uint16_t u16_req_stream;                          //req stream
    uint16_t u16_resp_stream;                         //resp stream
    int i_sign;                                       //event标志位
}L7session_cassandra_private;

static int __suite_init(void)
{

	return 0;
}

static int __suite_cleanup(void)
{

	return 0;
}

extern L7session_cassandra_private* __cassandra_private_create(void);
extern int __resp_data_analysis(Conntrack *p_st_conn
                                , Apm_packet *p_st_data_in
                                , Frhash_header *p_st_hash_report
                                , L7_session *p_st_session);
extern int cassandra_session_destroy(void *p_private_session);
extern void list_report_node_free(Frlist_node *p_st_node);

static void case1(void)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;
    Frhash_header *p_st_hash_report = NULL;
    L7_session *p_st_session = NULL;

    i_ret = __resp_data_analysis(p_st_conn, p_st_packet, p_st_hash_report, p_st_session);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);
    CU_ASSERT_PTR_EQUAL(p_st_session, NULL);

    return;
}

static void case2(void)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;
    L7_session *p_st_session = NULL;
    Frhash_header st_hash_report;
    L7session_cassandra_private *p_st_private = NULL;
    cassandra_report_list *p_st_report = NULL;
	Frlist_node *p_st_node = NULL;

    p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
    if(p_st_conn == NULL)
        goto ERROR;
    memset(p_st_conn, 0x00, sizeof(Conntrack));
    p_st_conn->flg_direct_known = FR_DIRECT_KNOWN;

    p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
    if(p_st_packet == NULL)
        goto ERROR;
    memset(p_st_packet, 0x00, sizeof(Apm_packet));
    p_st_packet->p_payload = (char *)"\x84\x00\x00\x01\x02\x00\x00\x00\x00";
    p_st_packet->ui_payload_len = 9;
    p_st_packet->st_timestamp.tv_sec = 10;
    p_st_packet->st_timestamp.tv_usec = 25;

    frhash2_create(&st_hash_report, 2);

    p_st_session = (L7_session *)frmalloc(sizeof(L7_session));
    if(p_st_session == NULL)
        goto ERROR;
    memset(p_st_session, 0x00, sizeof(L7_session));

    p_st_session->p_session_private = __cassandra_private_create();
    if(p_st_session->p_session_private == NULL)
        goto ERROR;
    p_st_private = (L7session_cassandra_private*)p_st_session->p_session_private;

    p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec = 0;
    p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec = 0;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_sec = 6;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_usec = 25;

    p_st_private->p_report_list_cassandra  = (Frhash_header *)frmalloc(sizeof(Frhash_header));
    if (p_st_private->p_report_list_cassandra == NULL)
        goto ERROR;
    memset(p_st_private->p_report_list_cassandra, 0x00, sizeof(Frhash_header));
    frhash2_create(p_st_private->p_report_list_cassandra, 2);
    p_st_report = (cassandra_report_list *)frmalloc(sizeof(cassandra_report_list));
    memset(p_st_report, 0x00, sizeof(cassandra_report_list));
    p_st_node = frlist_node_create(p_st_report);
    frhash2_addLong(p_st_private->p_report_list_cassandra, 1, p_st_node);

    i_ret = __resp_data_analysis(p_st_conn, p_st_packet, &st_hash_report, p_st_session);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SET_RESP(APM_L7_ANALYZE_SUCC));
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.l_response_bytes, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_usec, 0);

    frfree(p_st_conn);
    frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    cassandra_session_destroy(p_st_session->p_session_private);
    frfree(p_st_session);

    return;

ERROR:
    if(p_st_conn)
        frfree(p_st_conn);
    if(p_st_packet)
        frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    if(p_st_session)
    {
        if(p_st_session->p_session_private)
            cassandra_session_destroy(p_st_session->p_session_private);
        frfree(p_st_session);
    }
    return;
}

static void case3(void)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;
    L7_session *p_st_session = NULL;
    Frhash_header st_hash_report;
    L7session_cassandra_private *p_st_private = NULL;
    cassandra_report_list *p_st_report = NULL;
	Frlist_node *p_st_node = NULL;

    p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
    if(p_st_conn == NULL)
        goto ERROR;
    memset(p_st_conn, 0x00, sizeof(Conntrack));
    p_st_conn->flg_direct_known = FR_DIRECT_KNOWN;

    p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
    if(p_st_packet == NULL)
        goto ERROR;
    memset(p_st_packet, 0x00, sizeof(Apm_packet));
    p_st_packet->p_payload = (char *)"\x84\x00\x00\x01\x02\x00\x00\x00\x00";
    p_st_packet->ui_payload_len = 9;
    p_st_packet->st_timestamp.tv_sec = 10;
    p_st_packet->st_timestamp.tv_usec = 25;

    frhash2_create(&st_hash_report, 2);

    p_st_session = (L7_session *)frmalloc(sizeof(L7_session));
    if(p_st_session == NULL)
        goto ERROR;
    memset(p_st_session, 0x00, sizeof(L7_session));
    p_st_session->p_session_private = __cassandra_private_create();
    if(p_st_session->p_session_private == NULL)
        goto ERROR;
    p_st_private = (L7session_cassandra_private*)p_st_session->p_session_private;

    p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec = 0;
    p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec = 0;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_sec = 0;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_usec = 0;

    p_st_private->p_report_list_cassandra  = (Frhash_header *)frmalloc(sizeof(Frhash_header));
    if (p_st_private->p_report_list_cassandra == NULL)
        goto ERROR;
    memset(p_st_private->p_report_list_cassandra, 0x00, sizeof(Frhash_header));
    frhash2_create(p_st_private->p_report_list_cassandra, 2);
    p_st_report = (cassandra_report_list *)frmalloc(sizeof(cassandra_report_list));
    memset(p_st_report, 0x00, sizeof(cassandra_report_list));
    p_st_node = frlist_node_create(p_st_report);
    frhash2_addLong(p_st_private->p_report_list_cassandra, 1, p_st_node);

    i_ret = __resp_data_analysis(p_st_conn, p_st_packet, &st_hash_report, p_st_session);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SET_RESP(APM_L7_ANALYZE_SUCC));
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.l_response_bytes, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_usec, 0);

    frfree(p_st_conn);
    frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    cassandra_session_destroy(p_st_session->p_session_private);
    frfree(p_st_session);

    return;

ERROR:
    if(p_st_conn)
        frfree(p_st_conn);
    if(p_st_packet)
        frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    if(p_st_session)
    {
        if(p_st_session->p_session_private)
            cassandra_session_destroy(p_st_session->p_session_private);
        frfree(p_st_session);
    }
    return;
}

static void case4(void)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;
    L7_session *p_st_session = NULL;
    Frhash_header st_hash_report;
    L7session_cassandra_private *p_st_private = NULL;
    cassandra_report_list *p_st_report = NULL;
	Frlist_node *p_st_node = NULL;

    p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
    if(p_st_conn == NULL)
        goto ERROR;
    memset(p_st_conn, 0x00, sizeof(Conntrack));
    p_st_conn->flg_direct_known = FR_DIRECT_KNOWN;

    p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
    if(p_st_packet == NULL)
        goto ERROR;
    memset(p_st_packet, 0x00, sizeof(Apm_packet));
    p_st_packet->p_payload = (char *)"\x84\x00\x00\x00\x06\x00\x00\x00\x34\x00\x02\x00\x0b\x43\x4f\x4d\x50\x52\x45\x53\x53\x49\x4f\x4e\x00\x02\x00\x06\x73\x6e\x61\x70\x70\x79\x00\x03\x6c\x7a\x34\x00\x0b\x43\x51\x4c\x5f\x56\x45\x52\x53\x49\x4f\x4e\x00\x01\x00\x05\x33\x2e\x33\x2e\x31";
    p_st_packet->ui_payload_len = 61;
    p_st_packet->st_timestamp.tv_sec = 10;
    p_st_packet->st_timestamp.tv_usec = 25;

    frhash2_create(&st_hash_report, 2);

    p_st_session = (L7_session *)frmalloc(sizeof(L7_session));
    if(p_st_session == NULL)
        goto ERROR;
    memset(p_st_session, 0x00, sizeof(L7_session));
    p_st_session->p_session_private = __cassandra_private_create();
    if(p_st_session->p_session_private == NULL)
        goto ERROR;
    p_st_private = (L7session_cassandra_private*)p_st_session->p_session_private;

    p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec = 0;
    p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec = 0;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_sec = 6;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_usec = 25;

    p_st_private->p_report_list_cassandra  = (Frhash_header *)frmalloc(sizeof(Frhash_header));
    if (p_st_private->p_report_list_cassandra == NULL)
        goto ERROR;
    memset(p_st_private->p_report_list_cassandra, 0x00, sizeof(Frhash_header));
    frhash2_create(p_st_private->p_report_list_cassandra, 2);
    p_st_report = (cassandra_report_list *)frmalloc(sizeof(cassandra_report_list));
    memset(p_st_report, 0x00, sizeof(cassandra_report_list));
    p_st_node = frlist_node_create(p_st_report);
    frhash2_addLong(p_st_private->p_report_list_cassandra, 1, p_st_node);

    i_ret = __resp_data_analysis(p_st_conn, p_st_packet, &st_hash_report, p_st_session);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.l_response_bytes, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_usec, 0);

    frfree(p_st_conn);
    frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    cassandra_session_destroy(p_st_session->p_session_private);
    frfree(p_st_session);

    return;

ERROR:
    if(p_st_conn)
        frfree(p_st_conn);
    if(p_st_packet)
        frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    if(p_st_session)
    {
        if(p_st_session->p_session_private)
            cassandra_session_destroy(p_st_session->p_session_private);
        frfree(p_st_session);
    }
    return;
}

static void case5(void)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;
    L7_session *p_st_session = NULL;
    Frhash_header st_hash_report;
    L7session_cassandra_private *p_st_private = NULL;
    cassandra_report_list *p_st_report = NULL;
	Frlist_node *p_st_node = NULL;

    p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
    if(p_st_conn == NULL)
        goto ERROR;
    memset(p_st_conn, 0x00, sizeof(Conntrack));
    p_st_conn->flg_direct_known = FR_DIRECT_KNOWN;

    p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
    if(p_st_packet == NULL)
        goto ERROR;
    memset(p_st_packet, 0x00, sizeof(Apm_packet));
    p_st_packet->p_payload = (char *)"\x84\x00\xff\xff\x0c\x00\x00\x00\x31\x00\x0d\x53\x43\x48\x45\x4d\x41\x5f\x43\x48\x41\x4e\x47\x45\x00\x07\x43\x52\x45\x41\x54\x45\x44\x00\x08\x4b\x45\x59\x53\x50\x41\x43\x45\x00\x0d\x74\x65\x73\x74\x5f\x6b\x65\x79\x73\x70\x61\x63\x65";
    p_st_packet->ui_payload_len = 58;
    p_st_packet->st_timestamp.tv_sec = 10;
    p_st_packet->st_timestamp.tv_usec = 25;

    frhash2_create(&st_hash_report, 2);

    p_st_session = (L7_session *)frmalloc(sizeof(L7_session));
    if(p_st_session == NULL)
        goto ERROR;
    memset(p_st_session, 0x00, sizeof(L7_session));
    p_st_session->p_session_private = __cassandra_private_create();
    if(p_st_session->p_session_private == NULL)
        goto ERROR;
    p_st_private = (L7session_cassandra_private*)p_st_session->p_session_private;

    p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec = 0;
    p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec = 0;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_sec = 6;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_usec = 25;

    p_st_private->p_report_list_cassandra  = (Frhash_header *)frmalloc(sizeof(Frhash_header));
    if (p_st_private->p_report_list_cassandra == NULL)
        goto ERROR;
    memset(p_st_private->p_report_list_cassandra, 0x00, sizeof(Frhash_header));
    frhash2_create(p_st_private->p_report_list_cassandra, 2);
    p_st_report = (cassandra_report_list *)frmalloc(sizeof(cassandra_report_list));
    memset(p_st_report, 0x00, sizeof(cassandra_report_list));
    p_st_node = frlist_node_create(p_st_report);
    frhash2_addLong(p_st_private->p_report_list_cassandra, 1, p_st_node);

    i_ret = __resp_data_analysis(p_st_conn, p_st_packet, &st_hash_report, p_st_session);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SET_RESP(APM_L7_ANALYZE_SUCC));
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.l_response_bytes, 58);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec, 10);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec, 25);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_usec, 0);

    frfree(p_st_conn);
    frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    cassandra_session_destroy(p_st_session->p_session_private);
    frfree(p_st_session);

    return;

ERROR:
    if(p_st_conn)
        frfree(p_st_conn);
    if(p_st_packet)
        frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    if(p_st_session)
    {
        if(p_st_session->p_session_private)
            cassandra_session_destroy(p_st_session->p_session_private);
        frfree(p_st_session);
    }
    return;
}

static void case6(void)
{
    int i_ret = 0;
    Conntrack *p_st_conn = NULL;
    Apm_packet *p_st_packet = NULL;
    L7_session *p_st_session = NULL;
    Frhash_header st_hash_report;
    L7session_cassandra_private *p_st_private = NULL;
    cassandra_report_list *p_st_report = NULL;
	Frlist_node *p_st_node = NULL;

    p_st_conn = (Conntrack *)frmalloc(sizeof(Conntrack));
    if(p_st_conn == NULL)
        goto ERROR;
    memset(p_st_conn, 0x00, sizeof(Conntrack));
    p_st_conn->flg_direct_known = FR_DIRECT_KNOWN;

    p_st_packet = (Apm_packet *)frmalloc(sizeof(Apm_packet));
    if(p_st_packet == NULL)
        goto ERROR;
    memset(p_st_packet, 0x00, sizeof(Apm_packet));
    p_st_packet->p_payload = (char *)"\x84\x00\x00\x03\x08\x00\x00\x00\x6b\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x06\x00\x06\x73\x79\x73\x74\x65\x6d\x00\x05\x70\x65\x65\x72\x73\x00\x04\x70\x65\x65\x72\x00\x10\x00\x0b\x64\x61\x74\x61\x5f\x63\x65\x6e\x74\x65\x72\x00\x0d\x00\x04\x72\x61\x63\x6b\x00\x0d\x00\x06\x74\x6f\x6b\x65\x6e\x73\x00\x22\x00\x0d\x00\x0b\x72\x70\x63\x5f\x61\x64\x64\x72\x65\x73\x73\x00\x10\x00\x0e\x73\x63\x68\x65\x6d\x61\x5f\x76\x65\x72\x73\x69\x6f\x6e\x00\x0c\x00\x00\x00\x00";
    p_st_packet->ui_payload_len = 116;
    p_st_packet->st_timestamp.tv_sec = 10;
    p_st_packet->st_timestamp.tv_usec = 25;

    frhash2_create(&st_hash_report, 2);

    p_st_session = (L7_session *)frmalloc(sizeof(L7_session));
    if(p_st_session == NULL)
        goto ERROR;
    memset(p_st_session, 0x00, sizeof(L7_session));
    p_st_session->p_session_private = __cassandra_private_create();
    if(p_st_session->p_session_private == NULL)
        goto ERROR;
    p_st_private = (L7session_cassandra_private*)p_st_session->p_session_private;

    p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec = 0;
    p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec = 0;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_sec = 6;
    p_st_private->st_l4_trans.st_request_time_first_byte.tv_usec = 25;

    p_st_private->p_report_list_cassandra  = (Frhash_header *)frmalloc(sizeof(Frhash_header));
    if (p_st_private->p_report_list_cassandra == NULL)
        goto ERROR;
    memset(p_st_private->p_report_list_cassandra, 0x00, sizeof(Frhash_header));
    frhash2_create(p_st_private->p_report_list_cassandra, 2);
    p_st_report = (cassandra_report_list *)frmalloc(sizeof(cassandra_report_list));
    memset(p_st_report, 0x00, sizeof(cassandra_report_list));
    p_st_node = frlist_node_create(p_st_report);
    frhash2_addLong(p_st_private->p_report_list_cassandra, 1, p_st_node);

    i_ret = __resp_data_analysis(p_st_conn, p_st_packet, &st_hash_report, p_st_session);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.l_response_bytes, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time_first_byte.tv_usec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_sec, 0);
//    CU_ASSERT_EQUAL(p_st_private->st_l4_trans.st_response_time.tv_usec, 0);

    frfree(p_st_conn);
    frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    cassandra_session_destroy(p_st_session->p_session_private);
    frfree(p_st_session);

    return;

ERROR:
    if(p_st_conn)
        frfree(p_st_conn);
    if(p_st_packet)
        frfree(p_st_packet);
    frhash2_free(&st_hash_report, list_report_node_free);
    if(p_st_session)
    {
        if(p_st_session->p_session_private)
            cassandra_session_destroy(p_st_session->p_session_private);
        frfree(p_st_session);
    }
    return;
}

int add_suite__resp_data_analysis(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __resp_data_analysis()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", case1) == NULL ||
        CU_add_test(pSuite, "case2", case2) == NULL ||
        CU_add_test(pSuite, "case3", case3) == NULL ||
        CU_add_test(pSuite, "case4", case4) == NULL ||
        CU_add_test(pSuite, "case5", case5) == NULL ||
        CU_add_test(pSuite, "case6", case6) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
